{% extends 'base.html' %}

{% block contents %}
    
<h2>{{ filter_text }}</h2>

<form action="/borrow_to/" method="POST">
<table class="movie_list" id="example">
    <thead class="yellow">
	<tr>
	{% if its_you %}<th width="10">Check</th>{% endif %}
        <th>Title</th>
        <th>Owner</th>
        {% if review_mode or movie.review_mode %}
	{% else %}
	<th>Media</th>
	{% endif %}
	<th>Genre</th>
        {% if review_mode or movie.review_mode %}
	{% else %}
        <th>Buy</th>
	{% endif %}
        <th>IMDb</th>
        <th>Status</th>
	<th>Actions</th>
        <th>Kudos</th>
	<th>Rating</th>
	<th>Comments</th>
	</tr>
    </thead>
<tbody>
{% for movie in movies %}
<tr>
	{% if its_you %}
	    <td>{% if movie.is_available %}<input type="checkbox" name="{{movie.key}}" value="{{movie.key}}"/>{% else %}&nbsp;{% endif %}</td>
	{% endif %}
        <td class="title_cell"><a href="/movie/{{movie.key}}/">{{movie.title_}}</a></td>
        <td><a href="mailto:{{movie.contact_mail}}">{{movie.owner_nickname}}</a></td>
        {% if review_mode or movie.review_mode %}
	{% else %}
        <td>{{ movie.media_text }}</td>
	{% endif %}
	<td>{{ movie.genre_text }}</td>
        {% if review_mode or movie.review_mode  %}
	{% else %}
        <td>{% if movie.buy_url %}<a href="{{movie.buy_url}}">Buy it.</a>{% else %} &raquo;&nbsp;<a href="http://www.play.com/Search.aspx?searchtype=allproducts&searchstring={{movie.title_}}&page=search&pa=search&go.x=0&go.y=0">play.com</a>{% endif %}</td>
	{% endif %}
        <td><a href="{{movie.imdb_qs}}">ImDB.</a></td>
        <td>{{movie.status_text}}</td>
        <td>
            {% if movie.is_owner %}
            <a href="/delete/{{movie.key}}">Delete</a>&nbsp;<a href="/update/{{movie.key}}">Update</a>
            {% else %}

		{% if review_mode or movie.review_mode %}
		{% else %}
		    {% if movie.can_be_sold %}
			{% if movie.suggested_price %}
			<a href="/buy/{{movie.key}}">Buy for {{movie.suggested_price}}.</a>&nbsp;
			{% else %}
			<a href="/buy/{{movie.key}}">Buy</a>&nbsp;
			{% endif %}	   
		    {% endif %}	   
		    {% if movie.can_be_swapped %}	   
		    <a href="/swap/{{movie.key}}">Swap</a>&nbsp;
		    {% endif %}	   
		    {% if movie.can_be_borrowed %}	   
		    <a href="/borrow/{{movie.key}}">Borrow</a>
		    {% endif %}	   
		    {% if movie.can_give_kudos %}	   
		    <a href="/kudos/{{movie.key}}">Kudos</a>
		    {% endif %}            
    
		{% endif %}	   
	    {% endif %}
        </td>
	<td>
	{{movie.kudos_count}}
	</td>
	<td>
	<div class="rating">{{movie.calculated_rating}}</div>
	<a class="very_small" href="/give_rating/{{movie.key}}/1/">1</a>
	<a class="very_small" href="/give_rating/{{movie.key}}/2/">2</a>
	<a class="very_small" href="/give_rating/{{movie.key}}/3/">3</a>
	<a class="very_small" href="/give_rating/{{movie.key}}/4/">4</a>
	<a class="very_small" href="/give_rating/{{movie.key}}/5/">5</a>
	<a class="very_small" href="/give_rating/{{movie.key}}/6/">6</a>
	</td>
	<td>
	{{movie.comments_count}}
	</td>
</tr>
{%if movie.comments %}
<!--<tr>
    <td colspan="7">{{movie.comments}}</td>
</tr>-->
{% endif %}

{% endfor %}
</tbody>
</table>
<P/>
{% if its_you %}
Borrow the selected movies to 
<select name="the_loaner">
{% for loaner in loaners %}
  <option value="{{loaner.key}}">{{loaner.nickname}}</option>
{% endfor %}
</select> for <input type="text" name="due_in_days" value="3" size=2/> days.<input type="submit" value="Do it!"/>
{% endif %}

<!--<input type="submit" value="Process all selected movies"/>-->
</form>

{% endblock %}